package com.wxy.jk.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wxy.jk.common.enchance.MpLambdaQueryWrapper;
import com.wxy.jk.common.enchance.MpPage;
import com.wxy.jk.common.mapStruct.MapStructs;
import com.wxy.jk.mapper.DictTypeMapper;
import com.wxy.jk.pojo.po.DictType;
import com.wxy.jk.pojo.vo.PageVo;
import com.wxy.jk.pojo.vo.list.DictTypeVo;
import com.wxy.jk.pojo.vo.req.page.DictTypePageReqVo;
import com.wxy.jk.service.DictTypeService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class DictTypeServiceImpl extends ServiceImpl<DictTypeMapper, DictType> implements DictTypeService {


    @Override
    @Transactional(readOnly = true)
    public PageVo<DictTypeVo> list(DictTypePageReqVo query) {

        MpLambdaQueryWrapper<DictType> wrapper = new MpLambdaQueryWrapper<>();
        wrapper.like(query.getKeyword(), DictType::getName, DictType::getValue, DictType::getIntro);
        wrapper.orderByDesc(DictType::getId);
        return baseMapper.selectPage(new MpPage<>(query), wrapper).buildVo(MapStructs.INSTANCE::po2vo);
    }
}
